package com.xiti.student.base.input;

import com.baomidou.mybatisplus.annotations.TableName;
import com.jtys.common.utils.CodeUtils;
import com.jtys.order.entity.PlatformOrder;
import com.jtys.order.entity.enums.OrderPaymentStatusEnum;
import com.jtys.order.entity.enums.OrderStatusEnum;
import com.jtys.session.entity.SessionUser;
import com.jtys.user.entity.*;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;

/**
 * <p>
 * 平台订单表
 * </p>
 *
 * @author tangz
 * @since 2018-05-31
 */
@TableName("tb_o_platform_order")
public class PlatformOrderInput implements Serializable {

    private static final long serialVersionUID = 1L;
    /**
     * 客户ID
     */
    private Long userId;
    /**
     * 客户身份证
     */
    private String idCard;
    /**
     * 机构id
     */
    private Long orgId;
    /**
     * 医生id
     */
    private Long doctorId;
    /**
     * 说明
     */
    private String remark;

    public static PlatformOrder getNewPlatformOrder(PlatformOrderInput input, SessionUser sessionUser, User user, Org org, Doctor doctor, Account accountDoctor, Partner partner) {
        PlatformOrder order = new PlatformOrder();
        BeanUtils.copyProperties(input,order);
        order.setCode(CodeUtils.getUniqueID()); //TODO 类型 + 日期 + 序号
        order.setStatus((Integer) OrderStatusEnum.wait.getValue());
        order.setPaymentStatus((Integer) OrderPaymentStatusEnum.wait.getValue());
        order.setUserPhone(sessionUser.getUsername());
        order.setUserName(user.getName());
        order.setOrgTelephone(org.getTelephone());
        order.setOrgName(org.getName());
        order.setDoctorName(doctor.getName());
        order.setDoctorPhone(accountDoctor.getUsername());
        if(partner!=null){
            order.setPartnerId(partner.getId());
            order.setPartnerName(partner.getName());
        }
        order.setProvinceAdcode(org.getProvinceAdcode());
        order.setCityAdcode(org.getCityAdcode());
        order.setDistrictAdcode(org.getDistrictAdcode());
        return  order;
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getIdCard() {
        return idCard;
    }

    public void setIdCard(String idCard) {
        this.idCard = idCard;
    }

    public Long getOrgId() {
        return orgId;
    }

    public void setOrgId(Long orgId) {
        this.orgId = orgId;
    }

    public Long getDoctorId() {
        return doctorId;
    }

    public void setDoctorId(Long doctorId) {
        this.doctorId = doctorId;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }


}
